{template '_header'}
<script>document.title = "砍价活动"; </script>


<link rel="stylesheet" type="text/css" href="../addons/ewei_shopv2/plugin/bargain/static/css/iconfont.css">
<link rel="stylesheet" type="text/css" href="../addons/ewei_shopv2/plugin/bargain/static/css/style.css">
<link rel="stylesheet" type="text/css" href="../addons/ewei_shopv2/plugin/bargain/static/css/bargain.css">


    <script type="text/javascript">

        function GetUrlPara()
        {
            var url = document.location.toString();
            var arrUrl = url.split("?");

            var para = arrUrl[1];
            return para;
        }

        function GetUrlRelativePath()
        {
            var url = document.location.toString();
            var arrUrl = url.split("//");

            var start = arrUrl[1].indexOf("/");
            var relUrl = arrUrl[1].substring(start);//stop省略，截取从start开始到结尾的所有字符

            if(relUrl.indexOf("?") != -1){
                relUrl = relUrl.split("?")[0];
            }
            return relUrl;
        }

    </script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("#fuceng").click(function(){
                htmlobj=$.ajax({url:"{php echo mobileUrl('bargain/bargain');}&id={$id}&ajax=151",async:false});
                $("#myDiv").html(htmlobj.responseText);
            });
        });
    </script>
    <script language="javascript" type="text/javascript">
        var interval = 1000;
        function ShowCountDown(year,month,day,hour,minute,second,status,divname)
        {
            var now = new Date();
            var endDate = new Date(year, month-1, day,hour,minute,second);
            var leftTime=endDate.getTime()-now.getTime();
            var leftsecond = parseInt(leftTime/1000);
            //var day1=parseInt(leftsecond/(24*60*60*6));
            var day1=Math.floor(leftsecond/(60*60*24));
            var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
            var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
            var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
            var cc = document.getElementById(divname);
            if (status == 0) {
                cc.innerHTML = "未开始";
                return;
            }else if(status == 1){
                cc.innerHTML = "已结束";
                return;
            }else if(Number(day1)<0 || Number(hour) <0 || Number(minute) <0 || Number(second) <0){
                cc.innerHTML = "超过砍价时限";
                return;
            }else{
                cc.innerHTML = "剩余时间："+day1+"天"+hour+"小时"+minute+"分"+second+"秒";
            }
        }

        window.setInterval(function(){ShowCountDown({$year},{$month},{$day},{$hour},{$minute},{$second},{$status},'divdown1');}, interval);
    </script>


<div class='fui-page-group'>
    <div class='fui-page creditshop-detail-page'>
        {if is_h5app()}
        <div class="fui-header">
            <div class="fui-header-left">
                <a class="back" data-nocache="true"></a>
            </div>
            <div class="title">砍价活动</div>
            <div class="fui-header-right"></div>
        </div>
        {/if}
        <div class='fui-content'>
            <div class="bargain-header fui-list">
                <div class="fui-list-media">
                    <img src="{$res['head_image']}" alt="">
                </div>
                <div class="fui-list-inner">
                    <h2>{$res['nickname']}</h2>
                    <p>开砍时间：{$res['created_time']}</p>
                </div>
                <div><a href="{php echo mobileUrl('bargain');}" data-nocache="true">
                    <span class="icon icon-home1" style="float: right;width: 66px;color: red"> 首页</span></a>
                </div>
            </div>

            <div class="bargain-shop">
                <a href="{php echo mobileUrl('bargain/detail',array('id'=>$res2['id']));}" data-nocache="true" class="external">
                    <div class="bargain-shop-top fui-list">
                        <div class="fui-list-media">
                            <img src="{php $tt = json_decode($res2['images']);echo tomedia($tt[0]);}" alt="">
                        </div>
                        <div class="fui-list-inner">
                            <h2>{$res2['title']}</h2>
                            <p>库存{$res2['stock']} | 已售{$ewei_detail['sales']}</p>
                            <p id="divdown1"></p>
                        </div>
                    </div>
                </a>
                <div class="bargain-shop-price fui-list">
                    <div class="bargain-shop-price-item fui-list-inner active">
                        <i style="background: #fafafa">当前成交价</i>
                        <p>
                            <span class="price"><i>&yen;</i>{$res['now_price']}</span>
                            <span>原价 <del>&yen;{$res2['start_price']}</del></span>
                        </p>
                    </div>
                    <div class="bargain-shop-price-item fui-list-inner">
                        <i style="background: #fafafa">已砍金额</i>
                        <p>
                            <span class="price"><i>&yen;</i>{php echo -1*$res['bargain_price'];}</span>
                            <span>砍价次数 {$res['bargain_times']} 次</span>
                        </p>
                    </div>
                </div>
            </div>
            {if $swi === 111}
            <div class="bargain-shop-shop">


                {if $trade_swi==0}<span><a href="{php echo mobileUrl('order/create',array('bargainid'=>$res['id'],))}" class="left" data-nocache="">立即购买</a></span>{/if}
                {if $trade_swi==1}<span><a href="#" class="left " style="background-color:#ccc;" data-nocache="true">已经下单</a></span>{/if}
                {if $trade_swi==2}<span><a href="#" class="left " style="background-color:#ccc;" data-nocache="true">已经结束</a></span>{/if}
                {if $trade_swi==3}<span><a href="#" class="left " style="background-color:#ccc;" data-nocache="true">库存不足</a></span>{/if}
                {if $trade_swi==4}<span><a href="#" class="left " style="background-color:#ccc;" data-nocache="true">没到底价</a></span>{/if}
                {if $trade_swi==1}<span><a href="{php echo mobileUrl('order/detail',array('id'=>$res['order']));}" class="right " data-nocache="true"><i class="icon icon-cart"></i> 查看订单</a></span>{/if}

                {if $myself_swi && $trade_swi!=1}<span><a onclick="bargain()" class="right" id="fuceng"><i class="fu"></i>砍一刀</a></span>{/if}

                {if !$myself_swi && $trade_swi!=1}<span><a href="javascript:void(0)" onclick="FoxUI.alert('请复制链接发送给您的好友')" class="right "><i class="fu"></i>找人帮砍</a></span>{/if}
            </div>
            {/if}
            {if $swi === 222}
            <div class="bargain-shop-shop">
                <span><a href="{php echo mobileUrl('bargain/detail')}&id={$res2['id']}" class="left external">我也要砍</a></span>
                <span onclick="bargain()" id="fuceng"><a class="right "><i class="fu"></i>帮砍一刀</a></span>
            </div>
            {/if}

            <div class="bargain-list">
                <div class="bargain-list-top" id="bargainTab">
                    <a href="javascript:void(0);" data="family" class="active">亲友团</a>
                    <a href="javascript:void(0);" data="detail" class="sta">商品详情</a>
                    <a href="javascript:void(0);" data="rule" class="sta">活动规则</a>
                    {if $account_set['partin'] > -10000}<a href="javascript:void(0);" data="list">参与榜</a>{/if}
                </div>
                <div class="bargain-list-content" id="bargainTabContent">
                    <div class="bargain-list-content-item active" id="family">
                        <ul class="bargain-list-content-ul">
                            {if !empty($res3)}
                            {loop $res3 $key $value}
                            <li class="fui-list">
                                <div class="fui-list-media first"><img src="{$value['head_image']}" alt=""></div>
                                <div class="fui-list-inner">{$value['nickname']}</div>
                                <div class="fui-list-media three">{if $value['bargain_price'] <= 0}{$value['bargain_price']}元{/if}
                                    {if $value['bargain_price'] > 0} <font color="green">+{$value['bargain_price']}元</font>{/if}</div>
                                <div class="fui-list-media four">{php echo date('m/d  H:i',strtotime($value['bargain_time']));}</div>
                            </li>
                            {/loop}
                            {/if}
                            {if empty($res3)}
                            <li style="padding-top: 10px;text-align: center">
                                还没有人帮忙砍价
                            </li>
                            {/if}
                        </ul>
                    </div>

                    <div class="bargain-list-content-item" id="detail">
                        <div class="detail-info content content-images">
                        {php echo $ewei_detail['content'];}
                    </div></div>
                    <div class="bargain-list-content-item" id="rule"  style="margin:0cm 1cm 0cm 1cm;margin-top: 20px">
                        {if $res2['rule'] != null}{php echo htmlspecialchars_decode($res2['rule']);}{/if}
                        {if $res2['rule'] == null}{php echo htmlspecialchars_decode($account_set['rule']);}{/if}
                    </div>
                    {if $account_set['partin'] > -10000}<div class="bargain-list-content-item" id="list">
                        <ul class="bargain-list-content-ul">
                            {loop $res4 $key $value}
                            <li class="fui-list">
                                <div class="fui-list-media first"><img src="{$value['head_image']}" alt=""></div>
                                <div class="fui-list-inner">{$value['nickname']}</div>
                                <div class="fui-list-media three">{if $value['bargain_price'] <= 0}{$value['bargain_price']}元{/if}
                                    {if $value['bargain_price'] > 0} +{$value['bargain_price']}元{/if}
                                </div>
                                <div class="fui-list-media four">{php echo date('m/d  H:i',strtotime($value['update_time']));}</div>
                            </li>
                            {/loop}
                        </ul>
                    </div>{/if}
                </div>
            </div>
            <br>
            {template '_copyright'}
        </div>

    </div>

</div>

<!--<div id="mcover" onclick="this.style.display='none';" style="display: none;z-index: 1;"><div id="alert-mask" style="position:absolute;z-index:1;"></div><img src="/addons/ewei_shopv2/plugin/bargain/static/images/tishi.png" style="position:absolute;z-index:2;margin-top: 20%;margin-left: 10%;width: 80%"></div>-->
<script type="text/javascript">
    $(function(){
        $("#bargainTab a").on("click",function(){
            var id = $(this).attr("data");
            if(!$(this).hasClass("active")){
                $("#bargainTab a").removeClass("active");
                $(".bargain-list-content-item").hide();
                $(this).addClass("active")
                $("#"+id+"").fadeIn();
            }
        })
    });
    function show(){
        var pic = document.getElementById('mcover');
        pic.style.display = 'block';
    }
    function callback(){
        window.location="{php echo mobileUrl('bargain/bargain',array('id'=>$id,));}";
    }
    function bargain() {
        var res = document.getElementById('bargainres');
        res.style.display = 'block';
    }
    function tiao() {
        window.location.href = "{php echo mobileUrl('bargain/bargain',array('id'=>$res['id'],'rand'=>rand(1,10000)));}";
    }
</script>
<div style="display: none;" id="bargainres">
    <div class="lynn-bargain-bg" style="position:absolute;z-index:10000;height: 100%">

        <p>恭喜您</p>
        <span id="myDiv">1</span><br><br><br><br>
        <a class="lynn-bargain-bg-a" style="width: 130px;height: 35px;" onclick="tiao()"><span style="margin-top: 6px;font-size: 1.5em;color: #FFFFFF" data-nocache="">知道了</span></a>
    </div>
    <div id="alert-mask" style="position:absolute;z-index:1;"></div>
</div>
{template '_footer'}